package com.taotao.shopping.controller;

import com.taotao.common.core.domain.Result;
import com.taotao.shopping.domain.response.CartResponse;
import com.taotao.shopping.service.ShoppingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @className: ShoppingController
 * @author: ZhangYuQi
 * @date: 2024/12/27 下午3:51
 * @Version: 1.0
 * @description:
 */

@RestController
public class ShoppingController {

    @Autowired
    private ShoppingService shoppingService;

    /**
     * @Author ZhangYuQi
     * @Description 加入购物车
     * @Date 下午9:44 2024/12/26
     * @Param [skuId]
     * @return
     */
    @GetMapping("addToCart/{skuId}/{quantity}")
    public Result addToCart(@PathVariable("skuId") Long skuId, @PathVariable Integer quantity)
    {
        shoppingService.addToCart(skuId,quantity);
        return Result.success();
    }

    /**
    * @Author ZhangYuQi
    * @Description 获取当前登录用户购物车列表
    * @Date 上午11:05 2024/12/29
    * @Param []
    * @return
    */
    @GetMapping("shoppingCartList")
    public Result<List<CartResponse>> shoppingCartList()
    {
        List<CartResponse> cartResponse = shoppingService.shoppingCartList();
        return Result.success(cartResponse);
    }

}
